package com.iplant.base.utils.sql.orm;

import com.iplant.base.po.BasePO;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xiuto
 */
public class ORMUtils {

    private static final Map<String, PoService<? extends BasePO>> ImplMap = new HashMap<>();
    @SuppressWarnings("unused")
    public static <T1 extends BasePO> PoService<T1> GetPoService(Class<T1> wClazz) {
        return GetPoService(wClazz, null);
    }


    @SuppressWarnings("unchecked")
    public static synchronized <T1 extends BasePO> PoService<T1> GetPoService(Class<T1> wClazz, T1 ignoredDefaultValue) {
        if (wClazz == null) return null;
        if (!ImplMap.containsKey(wClazz.getName())) {
           // ImplMap.put(wClazz.getName(), new PoServiceImpl<T1>(wClazz, defaultValue));
            ImplMap.put(wClazz.getName(), new PoServiceImpl<T1>(wClazz));
        }
        return (PoService<T1>) (ImplMap.get(wClazz.getName()));
    }


}
